#ifndef PLAYWINDOW_H
#define PLAYWINDOW_H

#include <QMainWindow>
#include <QKeyEvent>
#include <qpainter.h>
#include <QVector>
#include <qstring.h>
#include <mypushbutton.h>

class PlayWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit PlayWindow(QWidget *parent = nullptr);


    void paintEvent(QPaintEvent * event);

    QRect CreateRect();
    void IsEat();
    void IsHit();

    void InitSnake();
    QVector<QRect> vSnakeRect;
    QRect SnakeHead;


    //定义槽函数
    void Snake_update();

    //定义键盘事件
    void keyPressEvent(QKeyEvent *key);

    //计时器
    QTimer *timer;

    //是否开始  是否结束
    bool blsRun;
    bool blsOver;
    QString sDisplay;

    //蛇移动的方向
    int nDirection;

    //食物
    QRect food;

    //得分
    int nScore;
    QString scoreLabel;

    //移动速度
    int speed;

signals:
};

#endif // PLAYWINDOW_H

